//
//  EndView.m
//  BTRIP
//
//  Created by dllo on 15/11/18.
//  Copyright © 2015年 johnbk. All rights reserved.
//

#import "EndView.h"

@implementation EndView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (void)dealloc{
    [_photoImage release];
    [_titleLabel release];
    [_descriptionLabel release];
    [super dealloc];
}


- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.photoImage = [[UIImageView alloc]initWithFrame:CGRectMake(10 * SWIDTH, 15 * SWIDTH, 60 * SWIDTH, 60 * SWIDTH)];
        self.photoImage.image = [UIImage imageNamed:@"tip"];
        self.photoImage.backgroundColor = [UIColor whiteColor];
        self.photoImage.layer.cornerRadius = self.photoImage.frame.size.width / 2;
        self.photoImage.layer.masksToBounds = YES;
        [self addSubview:self.photoImage];
        [_photoImage release];
       
        self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.photoImage.frame.size.width + self.photoImage.frame.origin.x + 5, self.photoImage.frame.origin.y + 5, KWIDTH - 40, 30 * SWIDTH)];
        self.titleLabel.text = @"旅行小贴士";
        
        [self addSubview:self.titleLabel];
        [_titleLabel release];
        
        self.descriptionLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.photoImage.frame.origin.x, self.photoImage.frame.size.height + self.photoImage.frame.origin.y + 15 * SWIDTH, KWIDTH - 20, 500 * SWIDTH)];
        self.descriptionLabel.numberOfLines = 0;
        [self.descriptionLabel setFont:[UIFont systemFontOfSize:14]];
        [self addSubview:self.descriptionLabel];
        [_descriptionLabel release];
        
    }
    return self;
}

-(void)setFirstDetail:(FirstDetailTravelModel *)firstDetail
{
    if (_firstDetail != firstDetail) {
        [_firstDetail release];
        _firstDetail = [firstDetail retain];
    }

    //拼接字符串
    NSArray *arr = [firstDetail.tip objectForKey:@"texts"];
    NSMutableString *string = [NSMutableString stringWithString:arr[0]];
    for (int i = 1; i < arr.count; i++) {
        [string appendString:arr[i]];
        [string appendString:@"\n\n\n"];
    }
    self.descriptionLabel.text = string;
//     NSLog(@"%@",self.descriptionLabel.text);
    
}


@end
